import java.io.IOException;
import java.util.logging.*;


/**
 * Logs errors
 * 
 * @author Zach 
 * @version 1.0
 * 
 */
public class Logs {

	/**
	 * Field handler.
	 */
	static FileHandler handler;
	/**
	 * Field l.
	 */
	private static Logger l;
	
	
	/**
	 * Constructor for Logs.
	 * @throws SecurityException
	 * @throws IOException
	 */
	public Logs() {
		
		try {
			handler = new FileHandler("log.txt");
		} catch (SecurityException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		l = Logger.getLogger("");
		
		l.addHandler(handler);
        l.setLevel(Level.ALL);
        l.info("Error logs");
		
	}
	
	/**
     * Method logError.
     * @param e Exception
     */
    public void logError(Exception e){
    	l.log(Level.ALL, e.getMessage(), e.getCause());
    }
    
    public void logNonError(Level level, String msg){
    	l.log(level,msg);
    }

    /**
     * Main method for testing purposes
     * @param args String[] Command line arguments
     * @throws Exception
     */
    public static void main(String args[]) throws Exception{ 
        l.addHandler(handler);
       
        l.setLevel(Level.ALL);
       
        l.info("Error logs");

        l.fine("");
    }
	
}
